package com.spc.demo.exceptionhandle;

import com.spc.demo.constant.Constant;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @author pingchao.su
 * @date 2022/7/13 20:25
 */
public class ExceptionallySerial {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //只有当发生异常时才会执行下面内容，否则返回原来的CompletableFuture
        CompletableFuture<String> first = Constant.cf.exceptionally(e -> {
            System.out.println("接收到异常");
            return "222223";
        });
        System.out.println(first.get());
    }
}
